package com.yummiii.dokueditor.model.doku;

import java.util.HashMap;
import java.util.List;

public class DokuNamespace extends DokuNSElement {
	String name;
	/**
	 * Conventions
	 * Key="pagename" for pages
	 * Key="namespace:" for namespaces
	 */
	
	HashMap<String,DokuNSElement> children;
	DokuNamespace father;
	
	public DokuNamespace(String name){
		this.name=name;
		children=new HashMap<String,DokuNSElement>();
	}
	public void setFather(DokuNamespace father){
		this.father=father;
	}
	public DokuNamespace addNamespace(String name){
		DokuNamespace ns=new DokuNamespace(name);
		ns.setFather(this);
		children.put(name+":", ns);
		return ns;
	}
	
	public boolean hasNamespace(String name){
		return children.containsKey(name+":");
	}
	
	public DokuNamespace getNamespace(String name){
		return (DokuNamespace) children.get(name+":");
	}
	
	public DokuPage addPage(String name,int mtime,int size){
		DokuPage dp=new DokuPage(name,mtime,size);
		dp.setFather(this);
		children.put(name, dp);
		return dp;
	}
	
	public boolean hasPage(String name){
		return children.containsKey(name);
	}
	
	public DokuPage getPage(String name){
		return (DokuPage) children.get(name);
	}
	
	public HashMap<String,DokuNSElement> getChildren(){
		return this.children;
	}
	
	public String getName(){
		return this.name;
	}
	
	@Override
	public DokuNSElement getFather() {
		return this.father;
	}
}
